{% extends 'task_market/base.html' %}
{% load static %}


{% block title %}
    任务市场
{% endblock %}

{% block content %}

    <div class="breadcrumbs">
        <div class="container">
            <div class="row">
                <div class="col-12">
                    <div class="bread-inner">
                        <ul class="bread-list">
                            <li><a href="{% url 'task_market:index' %}" target="_blank">主页<i
                                    class="ti-arrow-right"></i></a></li>
                            <li class="active"><a href="#">任务市场</a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <section class="product-area shop-sidebar shop section">
        <div class="container">
            <div class="col-lg-10 col-md-8 col-12 mx-auto">
                <div class="shop-top">
                    <div class="row">
                        <div class="col-lg-10 filter-single">
                            <div class="filter-content">
                                <div class="my-auto filter-title">任务类型: </div>
                                <select id="mySelect" onchange="redirectToPage()">
                                    <option value="{% url 'manager:task_admin' condition='checking' %}"
                                            {% if conditions == 'checking' %} selected="selected" {% endif %}>待审核
                                    </option>
                                    <option value="{% url 'manager:task_admin' condition='checked' %}"
                                            {% if conditions == 'checked' %} selected="selected" {% endif %}>已审核
                                    </option>
                                    <option value="{% url 'manager:task_admin' condition='finished' %}"
                                            {% if conditions == 'finished' %} selected="selected" {% endif %}>质量检测
                                    </option>
                                </select>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="row">
                    {% for task in tasks %}
                        <div class="col-lg-4 col-md-6 col-12 mt-4">
                            <div class="single-product">
                                <div class="product-img">
                                    {% if conditions == 'checking' %}
                                        <a href="{% url 'manager:task_check' id=task.id %}" target="_blank">
                                    {% elif conditions == 'checked' %}
                                        <a href="{% url 'manager:detail_everytask' id=task.id %}" target="_blank">
                                    {% elif conditions == 'finished' %}
                                        <a href="{% url 'manager:check_score' id=task.id %}" target="_blank">
                                    {% endif %}
                                    <img class="product-img"
                                         src="{% static 'temp_shop/assets/img/task001.png' %}" alt="#">
                                    <span class="out-of-stock">{{ task.id }}</span>
                                    </a>
                                </div>
                                <div class="product-content">
                                    {% if conditions == 'checking' %}
                                        <h3><a href="{% url 'manager:task_check' id=task.id %}"
                                               target="_blank">{{ task.task_name }}</a></h3>
                                    {% elif conditions == 'checked' %}
                                        <h3><a href="{% url 'manager:detail_everytask' id=task.id %}"
                                               target="_blank">{{ task.task_name }}</a></h3>
                                    {% elif conditions == 'finished' %}
                                        <h3><a href="{% url 'manager:check_score' id=task.id %}"
                                               target="_blank">{{ task.task_name }}</a></h3>
                                    {% endif %}
                                    <div class="d-flex justify-content-between">
                                        <div class="product-price" style="color: red;">
                                            <span>任务等级：{{ task.task_rank }}</span>
                                        </div>
                                    </div>
                                    <div class="d-flex justify-content-between">
                                        <div class="product-price">
                                            <span>薪资标准：{{ task.task_salary }}元/条</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    {% endfor %}
                </div>
                <div class="col-12">
                    <div class="pagination center">
                        <ul class="pagination-list">
                            <li><a href="#"><i class="ti-arrow-left"></i></a></li>
                            <li><a href="#">1</a></li>
                            <li class="active"><a href="#">2</a></li>
                            <li><a href="#">3</a></li>
                            <li><a href="#"><i class="ti-arrow-right"></i></a></li>
                        </ul>
                    </div>

                </div>
            </div>
        </div>

        </div>
    </section>
    <script>
        function redirectToPage() {
            var selectElement = document.getElementById("mySelect");
            var selectedOption = selectElement.options[selectElement.selectedIndex];

            if (selectedOption.value !== "") {
                window.location.href = selectedOption.value;
            }
        }
    </script>
{% endblock %}


{% block view %}

    {% for task in tasks %}
        <div class="modal" id="staticBackdrop{{ task.id }}" data-bs-backdrop="static" data-bs-keyboard="false"
             tabindex="-1" aria-labelledby="staticBackdrop" aria-hidden="true">
            <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
                <div class="modal-content">
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    <div class="modal-body">
                        <div class="row">
                            <div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
                                <img src="{% static 'temp_shop/assets/img/products/p1.png' %}" alt="#">
                            </div>
                            <div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
                                <div class="quickview-content">
                                    <div class="d-flex mb-3"></div>
                                    <h2>{{ task.task_name }}</h2>
                                    <div class="d-flex mb-3">
                                        <span>任务描述：</span>
                                    </div>
                                    <div class="d-flex mb-3">
                                        <b>{{ task.task_description }}</b>
                                    </div>
                                    <div class="d-flex mb-3"></div>
                                    <div class="d-flex mb-3">
                                        <span>薪资标准：</span>
                                    </div>
                                    <h2>{{ task.task_salary }}元/条</h2>
                                    <div class="add-to-cart">
                                        <a href="{% url 'task_market:details' id=task.id %}" class="btn">详情信息</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    {% endfor %}

{% endblock %}
